package oo3;

import java.util.Scanner;

public class PICC {

	String name;// 业务员姓名
	String tele;// 电话
	// 此业务员管理的客户资料
	String[] customer = new String[30];

	public void addNewCustomer(String name) {
		for (int i = 0; i < customer.length; i++) {
			if (customer[i] == null) {
				customer[i] = name;
				return;
			}
		}
		System.out.println("已满");
	}

	public void showNames() {
		System.out.println(name + "管理的客户有：");
		for (int i = 0; i < customer.length; i++) {
			if (customer[i] != null)
				System.out.print(customer[i] + "\t");
		}
		System.out.println();
	}

	// 查找客户
	public boolean search(String name) {
		// ?
		for (int v = 0; v < customer.length; v++) {

			if (customer[v] != null) {
				if (customer[v].equals(name)) {
					return true;
				}
			}
		}
		return false;
	}

	// 按照区间查找名字
	public boolean search2(int start, int end, String name) {
		int max = end > customer.length ? customer.length : end;
		for (int i = start; i < max; i++) {
			if (customer[i] != null && customer[i].equals(name))
				return true;
		}
		return false;
	}

	public boolean modifyName(String oldName, String newName) {
		// ?
		for (int v = 0; v < customer.length; v++) {
			if (customer[v] != null && customer[v].equals(oldName)) {
				customer[v] = newName;
				return true;
			}
		}
		return false;
	}
}
